import 'package:ladder_cash/app/app.dart';
import 'package:ladder_cash/app/com/view/carousel_view.dart';
import 'package:ladder_cash/app/key_mix.dart';
import 'package:ladder_cash/app/page/index/sign_in_view.dart';
import 'package:ladder_cash/generated/l10n.dart';
import 'package:ladder_cash/value/app_const.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:liuxlcommon/view/lxl_widget.dart';
import 'package:liuxlcommon/view/my_box.dart';
import 'package:liuxlcommon/view/my_style.dart';
import 'package:ladder_cash/app/page/index/index_logic.dart';
import 'package:ladder_cash/generated/assets.dart';

/// 大卡位
class LargeCardPage extends StatefulWidget {
  @override
  _LargeCardPageState createState() => _LargeCardPageState();
}

class _LargeCardPageState extends State<LargeCardPage> {
  IndexLogic logic = Get.find<IndexLogic>();

  @override
  void didChangeDependencies() {
    super.didChangeDependencies();
    // precacheImage(const AssetImage(Assets.bgSmallCardBg), context);
  }

  @override
  Widget build(BuildContext context) => App.localeEn ? abody : bbody;

  get bbody => ListView(
        padding: EdgeInsets.zero,
        children: [
          LStack([
            LColumn(lStyle: LStyle(width: 375.w), children: [
              LImage.easy(
                  App.localeEn ? Assets.molopNewLatop : Assets.molopNewLatopmx,
                  205.w,
                  375.w),
              8.lsh,
              tbg,
              8.lsh,
              LImage.easy(
                      App.localeEn
                          ? Assets.molopNewLabg2
                          : Assets.molopNewLabg2mx,
                      171.w,
                      359.w)
                  .onTapL(() => logic.clickApply(data)),
              56.lsh
            ])
          ])
        ],
      );

  get tbg => LColumn.eazy([
        30.lsh,
        LRow.eazy([
          35.lsw,
          LImage.easy(data['productLogo'.hx], 25.w, 25.w, 5.w),
          6.lsw,
          LText.easy("${data['productName'.hx]}*productName*", 16.sp, fw8,
                  Colors.white)
              .flex(1),
        ]),
        13.lsh,
        LText.easy("${data['amountRangeDes'.hx]}*amountRangeDes*", 15.sp, null,
                Colors.white)
            .size(null, 18.w),
        7.lsh,
        LText.easy("${data?['amountRange'.hx]}*Rage*", 40.sp, FontWeight.bold,
                Colors.white)
            .size(null, 48.w),
        10.lsh,
        LRow.eazy([
          LText.easy(data['termInfoDes'.hx] + ": *termInfoDes*", 12.sp, null,
              Colors.white),
          LText.easy(
              data['termInfo'.hx] + "*termInfo*", 12.sp, null, Colors.white),
          10.lsw,
          LText.easy(data['loanRateDes'.hx] + ":*loanRateDes*", 12.sp, null,
              Colors.white),
          LText.easy(
              data['loanRate'.hx] + "*loanRate*", 12.sp, null, Colors.white),
        ]).size(null, 18.w),
        52.lsh,
        LText.easy(
            data['buttonText'.hx] + "*buttonText*", 18.sp, fw7, Colors.white),
      ])
          .bgImg(Assets.molopNewLacar)
          .size(375.w, 270.w)
          .onTapL(() => logic.clickApply(data));

  // get topbox => LRow.eazy([
  //       LImage.easy(Assets.pcLargekf, 32.w, 32.w).onTapL(() {
  //         if (logic.indexData != null) {
  //           Get.to(MyWebPage(url: logic.indexData!['icon'.hx]['linkUrl'.hx]));
  //         }
  //       }),
  //       16.lsw,
  //     ]);
  //

  get t1css => '''height: 17px;
font-size: 12px; 
font-weight: 500; 
color: #999999;''';

  get t2css => '''
  text-align:center;
  flex:1;font-weight: 500;
font-size: 15px;
color: #FFFFFF;''';

  // 'termInfo' : 'stretch',
  // 'termInfoDes' : 'indications',
  // 'loanRate' : 'mainly',
  // 'loanRateDes' : 'subdominant',

  get data => logic.largeCardData ?? {};

  List banners = [
    Assets.molopNewB1bg,
    Assets.molopNewB2bg,
    Assets.molopNewB3bg
  ];

  get abody => ListView(
        padding: EdgeInsets.zero,
        children: [
          LStack([
            LColumn(lStyle: LStyle(width: 375.w), children: [
              LColumn.eazy([
                57.lsh,
                LText.easy(S.current.appName, 15.sp, fw7, Colors.white),
                10.lsh,
                CarouselView1(banners, (index) => banners[index], (index) {})
              ]).size(375.w, 273.w).bgImg(Assets.molopNewAlbg),
              tbg,
              8.lsh,
              Signinview('My gold coin >'),
              10.lsh
            ])
          ])
        ],
      );
}
